<?php
class Sosweb_Util_Common_Mail 
{
	private $title;
	private $message;
	private $to;
	private $from;
	
	function send()
	{
		$message = $this->prepareMail($this->title, $this->message);
		
		$mail = new Zend_Mail('utf-8');
		$mail->setBodyHtml($message)
		    ->setFrom($this->from[0], $this->from[1])
		    ->setSubject($this->title);
		
		if (is_array($this->to))
		{
			foreach ($this->to as $email)
			{
				$mail->addTo($email['email']);
			}
		}
		else
		{
			$mail->addTo($this->to);
		}
		
		$mail->send();		
	}
	
	function contactMessage($title, $message, $from)
	{
		$this->title = $title;
		$this->message = $message;
		$this->to = 'kontakt@azvision.pl';
		$this->from = array($from, $from);
		
		$this->send();
	}

	private function prepareMail($header, $message)
	{
		$mail =
			'<body style="line-height: 20px;"> '.
			'<strong style="color: #604582; font-family: Tahoma; font-size: 14px;"> '.
		 	$header.
			'</strong> '.
		 	'<br />'.
		 	'<br />'.
		 	'<p style="color: #000000; font-family: Tahoma; font-size: 12px;"> '.
			$message.
			'</p> '.
			'<br />'.
			'<br />'.
			'<strong style="margin: 2px 2px; color: #604582; font-family: Tahoma; font-size: 14px;">AZVISION</strong>'.
			'<p style="margin: 2px 2px; color: #000000; font-family: Tahoma; font-size: 12px;">ul. Karpacka 31A/41</p>'.
			'<p style="margin: 2px 2px; color: #000000; font-family: Tahoma; font-size: 12px;">85-050 Bydgoszcz</p>'.
			'<p style="margin: 2px 2px; color: #000000; font-family: Tahoma; font-size: 12px;">tel: + 48 660 419 218</p>'.
			'<p style="margin: 2px 2px;"><a style="font-family: Tahoma; font-size: 12px;" href="mailto:kontakt@azvision.pl" title="Wyślij email do azvision.pl">kontakt@azvision.pl</a></p> '.
			'<p style="margin: 2px 2px;"><a style="font-family: Tahoma; font-size: 12px;" href="http://www.azvision.pl" title="Przejdź na stronę azvision.pl">http://www.azvision.pl</a></p> '.
			'</body> ';
			
		return $mail;
	}
}